--- 战策七·暗度陈仓
local policy7 = fk.CreateSkill {
    name = "move_insecret",
    tgas = { Skill.Compulsory },
    dynamic_name = function (self, player, lang)
      return player == Self and self.name or "unknownpolicy"
    end,
    dynamic_desc = function (self, player, lang)
      return player == Self and self.name or "unknownpolicy"
    end,
}

local HG = require "packages/new_heg_diy_my/util"

Fk:loadTranslationTable {
    ["@[move_insecret_mark]"] = "暗度陈仓",
    ["move_insecret_ask"] = "战策-暗度陈仓：你可以选择一名本回合使用过【闪】或【无懈可击】的角色，对其造成1点伤害",
}

policy7:addEffect(fk.EventPhaseStart, {
    anim_type = "offensive",
    can_trigger = function(self, event, target, player, data)
        local mark_name = "@[private]" .. policy7.name .. "_mark"
        local targets = {}
        local logic = player.room.logic
        logic:getEventsOfScope(GameEvent.UseCard, 99, function(e)
            if e.data.card.trueName == "jink" or e.data.card.trueName == "nullification" then
                table.insertIfNeed(targets, e.data.from)
            end
        end, Player.HistoryTurn)
        event:setCostData(self, { tos = targets })
        return player:getMark(mark_name) ~= 0 and player.phase == Player.Finish and #targets > 0
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local tos = room:askToChoosePlayers(player, {
            targets = event:getCostData(self).tos,
            min_num = 1,
            max_num = 1,
            prompt = "move_insecret_ask",
            skill_name = "unknownpolicy",
            cancelable = true,
        })
        if #tos > 0 then
            event:setCostData(self, { tos = tos })
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local mark_name = "@[private]" .. policy7.name .. "_mark"
        local to = event:getCostData(self).tos[1]
        room:damage {
            from = player,
            to = to,
            damage = 1,
            skillName = policy7.name,
        }
        room:setPlayerMark(player, mark_name, 0)
        room:handleAddLoseSkills(player, "-move_insecret", nil, false)
        room.logic:trigger(HG.HegLosePolicy, player, { player, policy7.name })
    end,
})

return policy7
